package com.agent.commons.config;


import com.agent.commons.intercept.ModuleInterceptor;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Slf4j
@Component
public class AppConfig implements WebMvcConfigurer {
    /**
     * 放行路径白名单
     */
    private final List<String> allUrls= List.of("/user/**");

    @Resource
    private ModuleInterceptor moduleInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("🔥 模块拦截器生效!");
        registry.addInterceptor(moduleInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(allUrls)
        ;
    }
}
